           package com.java.diagnostics.visualizer.impl.axes;
           
           import com.java.diagnostics.visualizer.data.AggregateData;
           import com.java.diagnostics.visualizer.data.SourceData;
           import com.java.diagnostics.visualizer.data.TupleData;
           import com.java.diagnostics.visualizer.data.axes.DataAxis;
           import com.java.diagnostics.visualizer.impl.data.TupleDataImpl;
           import com.java.diagnostics.visualizer.impl.factory.LogFactory;
           import java.util.logging.Level;
           import java.util.logging.Logger;
           
           public class NormalisationMinimumFinder
           {
             private static final Logger TRACE = LogFactory.getTrace(NormalisationMinimumFinder.class);
             private static final double BIG_NUMBER = 9.223372036854776E+018D;
           
             public static double findMinimum(SourceData data, DataAxis dataAxis)
             {
               double minimum = 9.223372036854776E+018D;
           
               if (data != null)
               {
                 AggregateData dataSetData = data.getDataSetLevelData();
                 TupleData[] tupleDatas = dataSetData.getTupleData();
                 minimum = findMinimum(tupleDatas, dataAxis, minimum);
           
                 AggregateData variant = data.getVariantLevelData();
           
                 minimum = findMinimum(variant.getTupleData(), dataAxis, minimum);
               }
           
               if (minimum == 9.223372036854776E+018D) {
                 minimum = 0.0D;
               }
               return minimum;
             }
           
             private static double findMinimum(TupleData[] tupleDatas, DataAxis axis, double existingMinimum)
             {
               double minimum = existingMinimum;
           
               for (int i = 0; i < tupleDatas.length; i++) {
                 TupleDataImpl tuple = (TupleDataImpl)tupleDatas[i];
           
                 if ((!tuple.isEmpty()) && (tuple.getXAxis() == axis))
                 {
                   double xValue = tuple.getRawMinX();
           
                   if ((xValue < minimum) && (xValue >= 0.0D)) {
                     if (TRACE.isLoggable(Level.FINER)) {
                       TRACE
                         .finer("Normalisation finder found new minimum on " + 
                         tupleDatas[i].getLabel() + " of " + 
                         xValue);
                     }
                     minimum = xValue;
                   }
                 }
                 else if ((!tuple.isEmpty()) && (tuple.getYAxis() == axis)) {
                   double yValue = tuple.getRawMinY();
           
                   if ((yValue < minimum) && (yValue >= 0.0D)) {
                     minimum = yValue;
                   }
                 }
               }
               return minimum;
             }
           }

